package lzk.myshop.controller;

import com.alipay.api.AlipayApiException;
import lzk.myshop.service.impl.AlipayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/Alipay")
@CrossOrigin(origins = "*")
public class AlipayController {
    @Autowired
    AlipayServiceImpl alipayService;

    @RequestMapping("/pay")
    public void pay(int orderid, HttpServletResponse response) throws AlipayApiException, IOException {
        alipayService.pay(orderid,response);
    }

    @RequestMapping("/callback")
    public Map<String,Object> callback(HttpServletRequest request){
        return alipayService.callback(request);
    }
}
